public class LeetCode {
    public String addBinary(String a, String b) {
        StringBuilder sb = new StringBuilder();
        int t = 0;
        int l1 = a.length() - 1;
        int l2 = b.length() - 1;
        while(l1>=0 || l2>=0 || t!=0){
            if(l1>=0){
                t+=a.charAt(l1--) - '0';
            }
            if(l2>=0){
                t+=b.charAt(l2--) - '0';
            }
            sb.append((char) ((char) (t%2)+'0'));
            t/=2;
        }
        sb.reverse();
        return sb.toString();
    }
}
